﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MsForgeReboot.Tests.Controllers
{
    using System.Collections.Generic;
    using System.Web.Mvc;

    using Moq;

    using MsForgeReboot.Framework.Entities;
    using MsForgeReboot.Framework.Interfaces;
    using MsForgeReboot.Web.Controllers;

    using PagedList;

    [TestClass]
    public class UserGroupControllerTests
    {
        private Mock<IUserGroupService> userGroupService;

        [TestInitialize]
        public void TestInitialize()
        {
            this.userGroupService = new Mock<IUserGroupService>();
        }

        [TestCleanup]
        public void TestCleanUp()
        {
            this.userGroupService = null;
        }

        [TestMethod]
        public void InstantiateUserGroupController()
        {
            var controller = new UserGroupController(this.userGroupService.Object);
            Assert.IsNotNull(controller);
        }

        [TestMethod]
        public void ListAllUserGroups()
        {
            this.userGroupService.Setup(service => service.GetList(1, 10))
                .Returns(new List<UserGroup>().ToPagedList(1, 10));

            var controller = new UserGroupController(this.userGroupService.Object);

            var result = controller.Index() as ViewResult;

            Assert.IsInstanceOfType(result.Model, typeof(IPagedList<UserGroup>));

            this.userGroupService.VerifyAll();
        }

    }
}
